package com.example.aisqlmcp.mcp.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MCPWebMvcConfig implements WebMvcConfigurer {
    
    @Autowired
    private MCPApiKeyInterceptor apiKeyInterceptor;
    
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册拦截器，只拦截MCP相关的端点
        registry.addInterceptor(apiKeyInterceptor)
                .addPathPatterns("/api/v1/sse", "/api/v1/mcp/**");
    }
}